package com.sw.chinesewriteboard.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.sw.chinesewriteboard.R;
import com.sw.chinesewriteboard.activity.DetailActivity;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;

public class FileListAdapter extends BaseQuickAdapter<File, BaseViewHolder> {

    public FileListAdapter(int layoutResId, @Nullable java.util.List<File> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, File file) {
        Glide.with(getContext()).load(file).into((ImageView) baseViewHolder.getView(R.id.iv));
        baseViewHolder.getView(R.id.iv).setOnClickListener(v -> {
            DetailActivity.start(baseViewHolder.getView(R.id.iv).getContext(), file.getAbsolutePath());
        });
//        String text =  new SimpleDateFormat("yyyy-MM-dd").format(new Date(file.lastModified()));
//        baseViewHolder.setText(R.id.tv_desc,text);
    }
}
